package com.xiaohai.haiaiagent.demo.invoke;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

// 取消注释即可在 SpringBoot 项目启动时执行

/**
 * Spring AI 方式测试调用本地部署的AI大模型（Ollama）
 */
//@Component
public class OllamaAiInvoke implements CommandLineRunner {

    @Resource
    private ChatModel ollamaChatModel;
    @Override
    public void run(String... args) throws Exception {
        AssistantMessage output =ollamaChatModel.call(new Prompt("你好，我是小海"))
                .getResult()
                .getOutput();
        System.out.println(output.getText());
    }
}
